package com.luom.usercenter.mapper;

import com.luom.usercenter.model.User;
import com.luom.usercenter.model.request.UserUpdateRequest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper{

    @Select("select *from user where user_account=#{userAccount}")
    User getByUserAccount(String userAccount);

//    @Insert("insert into user (user_account,user_password)values (#{userAccount},#{userPassword})")
    void save(User user);

    @Select("select *from user where user_account=#{userAccount} and user_password=#{newPassword}")
    User getByAccountAndPassword(String userAccount, String newPassword);

    @Select("select *from user where username like #{username}")
    List<User> searchUsers(String username);


    @Delete("delete from user where id=#{id}")
    boolean deleteUser(Long id);

    @Select("select *from user")
    List<User> searchAllUsername(String username);

    @Select("select * from user where id=#{id} and is_delete!=1;")
    User getById(Long id);


    void updateUser(UserUpdateRequest userUpdateRequest);
}